{include file="pageheader_erp.htm"}

<link href="styles/erp_delivery.css" rel="stylesheet" type="text/css" />

{insert_scripts files="../js/jquery.1.3.2.js"}
{insert_scripts files="../js/jquery.blockUI.2.23.js"}

{include file="erp_delivery_search.htm"}

<style type="text/css">
	.current_page_style
	{
		color:red;
		font-weight:bold;
	}
	
</style>

<script type=text/javascript>
	
	function view_approve_remark(delivery_id)
	{
		$.blockUI({ 
		  message: $('#approve_remark_'+delivery_id), css: { 
		  top:  ($(window).height()-300) /2 + 'px', 
		  left: ($(window).width()-500) /2 + 'px'
		  }
		});	
	}
	
	$(document).ready(function(){
		$("img[id^='img_close_approve_remark_']").click(function(){
			$.unblockUI();
		});
		$("img[id^='img_submit_approve_']").click(function(){
			$.unblockUI();
		});	
			
	});
	
</script>


{foreach from=$delivery_info item=delivery_info_item}
{if $delivery_info_item.status eq 3 or $delivery_info_item.status eq 4}

<div class="approve_remark" id="approve_remark_{$delivery_info_item.delivery_id}">
<div class="approve_remark_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/approve_remark.gif" />
			</td>
			<td align="right">
				<span><img style="cursor:pointer;" id="img_close_approve_remark_{$delivery_info_item.delivery_id}" src="./images/close_erp.gif" /></span>
			</td>
		</tr>
	</table>
</div>

<div class="approve_remark_box">
<table  cellpadding="5" cellspacing="0" border='0'>
	 <tr>
    	<td width="60">{$lang.erp_approve_remark}</td>	
		<td>
			<textarea rows="8" cols="55" disabled="true" id="textarea_approve_remark_{$delivery_info_item.delivery_id}">{$delivery_info_item.approve_remark}</textarea>
		</td>
	</tr>	
</table>
</div>
<div class="div_submit_approve">
	<img style="cursor:pointer;" id="img_submit_approve_{$delivery_info_item.delivery_id}" src="./images/submit.gif" />
</div>	
</div>

{/if}
{/foreach}


<!-- start delivery list -->
 <div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th  width="5%">{$lang.erp_delivery_id}</th>
    <th>{$lang.erp_delivery_sn}</th>	
	<th>{$lang.erp_delivery_warehouse}</th>
	<th>{$lang.erp_delivery_admin}</th>		
 	<th>{$lang.erp_delivery_delivery_style}</th>	
	<th>{$lang.erp_delivery_order}</th>	
	<th>{$lang.erp_delivery_to}</th>
	<th>{$lang.erp_delivery_date}</th>
	<th>{$lang.erp_delivery_status}</th>
	<th width="15%">{$lang.erp_operation}</th>
  </tr>
  {foreach from=$delivery_info key=key item=delivery_info_item}
 	<tr>
 		<td align="center">{$delivery_info_item.delivery_id}</td>
		<td align="center">{$delivery_info_item.delivery_sn}</td>
		<td align="center">{$delivery_info_item.warehouse_info.name}</td>
		<td align="center">{$delivery_info_item.admin_name}</td>
		<td align="center">{$delivery_info_item.delivery_style_info.delivery_style}</td>
		<td align="center">{$delivery_info_item.order_info.order_sn}</td>
		<td align="center">{$delivery_info_item.delivery_to}</td>
		<td align="center">{$delivery_info_item.delivery_date}</td>
		<td align="center">
			{if $delivery_info_item.status eq 1}{$lang.erp_delivery_status_inputing}{/if}
			{if $delivery_info_item.status eq 2}{$lang.erp_delivery_status_approving}{/if}
			{if $delivery_info_item.status eq 3}<span style="color:blue;">{$lang.erp_delivery_status_approve_pass}</span>{/if}
			{if $delivery_info_item.status eq 4}<span style="color:red;">{$lang.erp_delivery_status_approve_reject}</span>{/if}
		</td>
		<td align="center">
			{if $delivery_info_item.available_act.view eq 1}
				<a href="erp_warehouse_manage.php?act=view_delivery&id={$delivery_info_item.delivery_id}">{$lang.erp_operation_view}</a>
				{if $delivery_info_item.status eq 3 or $delivery_info_item.status eq 3 }
					<a href="javascript:view_approve_remark({$delivery_info_item.delivery_id})">{$lang.erp_delivery_operation_approve_remark}</a>
				{/if}
				{if $delivery_info_item.status eq 3}
					<a target="_blank" href="erp_warehouse_manage.php?act=print_delivery&id={$delivery_info_item.delivery_id}">{$lang.erp_operation_print}</a>
				{/if}
			{/if}
			
			{if $delivery_info_item.available_act.edit eq 1}
				<a href="erp_warehouse_manage.php?act=edit_delivery&id={$delivery_info_item.delivery_id}">{$lang.erp_operation_edit}</a>
			{/if}
			{if $delivery_info_item.available_act.delete eq 1}
				<a href="javascript:delete_delivery({$delivery_info_item.delivery_id})">{$lang.erp_operation_delete}</a>
			{/if}
			{if $delivery_info_item.available_act.post_to_approve eq 1}
				<a href="javascript:post_delivery({$delivery_info_item.delivery_id})">{$lang.erp_operation_post_to_approve}</a>
			{/if}				
					
			{if $delivery_info_item.available_act.approve eq 1}
				<a href="erp_warehouse_manage.php?act=approve_delivery&id={$delivery_info_item.delivery_id}">{$lang.erp_operation_approve}</a>
				<a href="javascript:withdrawal_to_edit({$delivery_info_item.delivery_id})">{$lang.erp_operation_withdrawal}</a>
			{/if}
		</td>
 	</tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
  <tr><td colspan="10" align="right">{$page}</td></tr> 
</table>
</div>
<!-- end delivery list -->

{literal}
<script language="JavaScript">

	function add_delivery()
	{
		function addDeliveryResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location='./erp_warehouse_manage.php?act=edit_delivery&id='+res.delivery_id;
			}			
		}
		
		Ajax.call('erp_delivery.php?act=add_delivery', '', addDeliveryResponse, 'POST', 'JSON');
	}
	
	function withdrawal_to_edit(delivery_id)
	{
		function withdrawalToEditResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_warehouse_manage.php?act=delivery_list";
			}
		}
		if(confirm('{$lang.erp_warehousing_sure_to_withdrawal_to_edit}'))
		{	
			Ajax.call('erp_delivery.php?act=withdrawal_to_edit', 'delivery_id=' + delivery_id, withdrawalToEditResponse, 'POST', 'JSON');
		}			
	}	

	function post_delivery(delivery_id)
	{
		function postDeliveryResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_warehouse_manage.php?act=delivery_list";
			}				
		}
		if(confirm('{$lang.erp_delivery_sure_to_post_delivery}'))
		{
			Ajax.call('erp_delivery.php?act=post_delivery', 'delivery_id='+delivery_id, postDeliveryResponse, 'POST', 'JSON');
		}
	}
	
	function delete_delivery(delivery_id)
	{
		function deletedeliveryResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="erp_warehouse_manage.php?act=delivery_list";;
			}			
		}
		if(confirm('{$lang.erp_delivery_sure_to_delete_delivery}'))
		{	
			Ajax.call('erp_delivery.php?act=delete_delivery', 'delivery_id='+delivery_id, deletedeliveryResponse, 'POST', 'JSON');
		}			
	}
	
</script>
{/literal}
{include file="pagefooter.htm"}

